

package com.hazelcast.spi.impl.sequence;

import com.hazelcast.internal.util.ConcurrencyDetection;

public final class CallIdFactory {

    private CallIdFactory() {
    }

    public static CallIdSequence newCallIdSequence(int maxConcurrentInvocations, long backoffTimeoutMs, ConcurrencyDetection concurrencyDetection) {
        if (concurrencyDetection.enabled()) {
            if (backoffTimeoutMs > 0) {
                return new CallIdSequenceWithBackpressure(maxConcurrentInvocations, backoffTimeoutMs, concurrencyDetection);
            } else {
                return new FailFastCallIdSequence(maxConcurrentInvocations, concurrencyDetection);
            }
        } else {
            return new CallIdSequenceWithoutBackpressure();
        }
    }
}
